@extends('admin.layout.index')

@section('content')

<div class="mws-panel grid_8">
  <div class="mws-panel-header">
    <span>
      <i class="icon-table"></i>{{$title}}</span>
  </div>
  <div class="mws-panel-body no-padding">
    <div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">
      <div id="DataTables_Table_1_length" class="dataTables_length">
      <form action="{{url('admin/recommend')}}" method="get">
        <label>显示
          <select size="1"  name="count" aria-controls="DataTables_Table_1">
            <option value="4" @if(!empty($request['count']) && $request['count'] == 4) selected @endif>4</option>
            <option value="6" @if(!empty($request['count']) && $request['count'] == 6) selected @endif>6</option>
            </select>　条</label>
      </div>
      <div class="dataTables_filter" id="DataTables_Table_1_filter">
        <label>关键字:
          <input type="text" aria-controls="DataTables_Table_1" name="search" value="{{$request['search'] or ''}}">
          <input type="submit" class="btn btn-success btn-xs" value="搜索"></label></div>
        </form>
      <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
        <thead>
          <tr>
            <th>推荐位ID</th>
            <th>推荐位标题</th>
            <th>推荐商品描述</th>
            <th>推荐商品图片</th>
            <th>推荐位链接</th>
            <th>是否上架</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody role="alert" aria-live="polite" aria-relevant="all">
        @foreach($data as $k=>$v)
          <tr class="odd">
            <td class="  sorting_1">{{$v->id}}</td>
            <td class=" ">{{$v->re_name}}</td>
            <td class=" ">{{$v->re_description}}</td>
            <td class=" "><img src="http://lamp187mall.oss-cn-beijing.aliyuncs.com/uploads/{{$v->re_photo}}" alt="" width="80px" height="80px"></td>
            
            <td class=" ">{{$v->re_link}}</td>
            <td class=" ">{{$v->re_status == 0 ? '未上架':'上架' }}</td>
            <td>
                <a href="javascript:void(0)" onclick="delRecommend({{$v->id}})"><button class="btn btn-warning">删除</button></a>　
                <a href="{{asset('admin/recommend/'.$v->id.'/edit')}}"><button class="btn btn-info">修改</button></a>
            </td>
          </tr>
        @endforeach
        </tbody>
      </table>
      <script>
        function delRecommend($pid){

            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('admin/recommend/')}}/'+$pid,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
//                    删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            });
        }

      </script>
      
      <!-- <div class="dataTables_paginate paging_full_numbers" id="DataTables_Table_1_paginate">
        <a tabindex="0" class="first paginate_button paginate_button_disabled" id="DataTables_Table_1_first">First</a>
        <a tabindex="0" class="previous paginate_button paginate_button_disabled" id="DataTables_Table_1_previous">Previous</a>
        <span>
          <a tabindex="0" class="paginate_active">1</a>
          <a tabindex="0" class="paginate_button">2</a>
          <a tabindex="0" class="paginate_button">3</a>
          <a tabindex="0" class="paginate_button">4</a>
          <a tabindex="0" class="paginate_button">5</a></span>
        <a tabindex="0" class="next paginate_button" id="DataTables_Table_1_next">Next</a>
        <a tabindex="0" class="last paginate_button" id="DataTables_Table_1_last">Last</a></div> -->
        <div id="page_page" class="">
            {!! $data->appends(['count'=>$count,'search'=>$search])->render() !!}
        </div>
    </div>
  </div>
</div>

@endsection